/*
 * Create a recurring event
 */ 

// Create the calendar service object
var calendarService = new google.gdata.calendar.CalendarService('GoogleInc-jsguide-1.0');

// The default "private/full" feed is used to insert event to the 
// primary calendar of the authenticated user
var feedUri = 'http://www.google.com/calendar/feeds/default/private/full';

// Create an instance of CalendarEventEntry representing the new event
var entry = new google.gdata.calendar.CalendarEventEntry();

// Set the title of the recurring event
entry.setTitle(google.gdata.Text.create('JS-Client: insert recurring event'));

// Set up the recurring details using an ical string (RFC 2445 http://www.ietf.org/rfc/rfc2445.txt) 
var recurrence = new google.gdata.Recurrence();
var icalBreak = '\r\n';
var recurrenceString = 'DTSTART;TZID=America/Los_Angeles:20080101T080000' + icalBreak + 
    'DTEND;TZID=America/Los_Angeles:20080101T090000' + icalBreak +
    'RRULE:FREQ=WEEKLY;UNTIL=20080701T160000Z;';
recurrence.setValue(recurrenceString);
entry.setRecurrence(recurrence);

// This callback method that will be called after a successful insertion from insertEntry()
var callback = function(result) {
  PRINT('event created!');
}

// Error handler will be invoked if there is an error from insertEntry()
var handleError = function(error) {
  PRINT(error);
}

// Submit the request using the calendar service object
calendarService.insertEntry(feedUri, entry, callback, 
    handleError, google.gdata.calendar.CalendarEventEntry);

